﻿using System;
using System.Diagnostics;
using System.Linq;

namespace Problem009
{
    class Program
    {
        private const int MAX_VALUE = 1000;

        static void Main()
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            var product = (from a in Enumerable.Range(1, MAX_VALUE)
                          from b in Enumerable.Range(a, MAX_VALUE - a)
                          let c = MAX_VALUE - a - b
                          where c > 0
                          where Math.Pow(c, 2) == Math.Pow(a, 2) + Math.Pow(b, 2)
                          select a * b * c).Single();
            stopwatch.Stop();

            Console.WriteLine(product);
            Console.WriteLine("Execution time: {0}ms", stopwatch.ElapsedMilliseconds);

            Console.ReadKey();
        }
    }
}
